package test

import ninenineqs._

/**
  * Created by wyc on 6/11/2017.
  * Find out whether a list is a palindrome.
  * Example:
  * scala> isPalindrome(List(1, 2, 3, 2, 1))
  * res0: Boolean = true
  */

class test_p06 extends UnitSpec{
  feature(this.getClass.toString) {
    val L1 = List(1, 2, 3, 2, 1)
    val L2 = List[Int]()
    val L3 = List(4)
    val L4 = List(1, 2, 3, 3, 2, 1)
    val L5 = List(1, 2, 3, 3, 2, 2)
    val L6 = List(1, 2, 3, 2, 2)

    val Ts:List[(List[Int]) => Boolean]=List(
      p06.isPalindrome_v1,
      p06.isPalindrome_v2
    )

    var v = 1
    for ( func <- Ts ) {
      scenario("isPalindrome_v" + v) {
        func(L1) shouldBe true
        func(L2) shouldBe true
        func(L3) shouldBe true
        func(L4) shouldBe true
        func(L5) shouldBe false
        func(L6) shouldBe false
      }
      v += 1
    }
  }
}
